package org.example.aienglishapp;

import java.util.Base64;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

public class AesKeyGenerator {
    public AesKeyGenerator() {
    }

    public static void main(String[] args) throws Exception {
        KeyGenerator keyGen = KeyGenerator.getInstance("AES");
        keyGen.init(128);
        SecretKey secretKey = keyGen.generateKey();
        String encodedKey = Base64.getEncoder().encodeToString(secretKey.getEncoded());
        System.out.println("Generated AES Key (Base64): " + encodedKey);
        byte[] decodedKey = Base64.getDecoder().decode(encodedKey);
        new SecretKeySpec(decodedKey, "AES");
    }
}
